package com.aaa.service.impl;

import com.aaa.entity.TabRoleMenu;
import com.aaa.mapper.TabRoleMenuMapper;
import com.aaa.service.ITabRoleMenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 于永利
 * @since 2024-08-03
 */
@Service
public class TabRoleMenuServiceImpl extends ServiceImpl<TabRoleMenuMapper, TabRoleMenu> implements ITabRoleMenuService {


    @Override
    public void updRolePre(Integer rid, List<Integer> mids) {
        // 先删除  后添加
        Map<String, Object> map = new HashMap<>();
        map.put("rid", rid);
        this.removeByMap(map);
        // 添加

        for (int i = 0; i < mids.size(); i++) {
            TabRoleMenu tabRoleMenu = new TabRoleMenu(rid,mids.get(i));
            this.save(tabRoleMenu);
        }

    }
}
